package hexagon.security.service.impl;

import com.avaje.ebeaninternal.server.util.Md5;
import hexagon.security.core.domain.User;
import hexagon.security.service.HexagonSecurity;

import java.util.UUID;

/**
 * @author XueguiYuan
 * @version 1.0 (created time: 2016/12/10).
 */
public class HexagonSecurityImpl implements HexagonSecurity {
    @Override
    public User getUserByAccessToken(String accessToken) {
        return User.find.where()
                .eq("accessToken", accessToken).findUnique();
    }

    @Override
    public String generateAccessToken() {
        return Md5.hash(UUID.randomUUID().toString());
    }
}
